<?php

use think\migration\Migrator;
use think\migration\db\Column;

class AuthRules extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
        $table = $this->table('auth_rules', array('engine' => 'MyISAM','comment'=>'节点表'));
        $table->addColumn('name', 'string', array('limit' => 15, 'default' => '', 'comment' => 'url地址'))
            ->addColumn('title', 'string', array('limit' => 25, 'default' => '', 'comment' => '规则名称'))
            ->addColumn('parent_id', 'integer', array('limit' => 11, 'default' => 0, 'comment' => '父ID'))
            ->addColumn('icon', 'string', array('limit' => 32, 'default' => '', 'comment' => '图标','null' => true))
            ->addColumn('ismenu', 'integer', array('limit' => 1, 'default' => 0, 'comment' => '是否为菜单'))
            ->addColumn('status', 'boolean', array('limit' => 1, 'default' => 1, 'comment' => '状态'))
            ->addColumn('sort_order', 'integer', array('limit' => 40, 'default' => 0, 'comment' => '排序'))
            ->addTimestamps()
            ->addSoftDelete()
            ->create();
    }
}
